package org.flexqueries2.core
{
	import org.flexqueries2.utils.date.DateUtils;

	public class SqlField
	{
		private var _xmlData:XML;
		
		public function SqlField(x:XML)
		{
			_xmlData = x;
		}
		
		/**
		 * Retourne la valeur en tant que String
		 */ 
		public function get asString():String
		{
			return _xmlData.toString();
		}
		
		/**
		 * Retourne la valeur en tant que Number
		 */ 
		public function get asNumber():Number
		{
			return Number(this.asString);
		}
		
		/**
		 * Retourne la valeur en tant que Date
		 */ 
		public function get asDate():Date
		{
			try
			{
				return DateUtils.toDateTime(this.asString);
			}
			catch(e:Error) { }
			
			return null;
		}
		
		public function setValue(value:String):void
		{
			_xmlData.setChildren(value);
		}
						
	}
}